<?php
/**
 * Created by PhpStorm.
 * User: xuyiping
 * Date: 2019/1/25
 * Time: 16:27
 */

require 'config.php';

//连接
$conn = new AMQPConnection($conn_args);

if(!$conn->connect()){
    die('Cannot connect to the broke!\n');
}

//创建管道
$channel = new AMQPChannel($conn);

//创建交换机
$e_name = 'e_linvo';

//路由
$k_route = 'key_1';

$ex = new AMQPExchange($channel);
$ex->setName($e_name);
$ex->setType(AMQP_EX_TYPE_DIRECT); //direct类型
$ex->setFlags(AMQP_DURABLE); //持久化


echo "Exchange Status:".$ex->declareExchange()."\n";

for ($i = 0; $i < 10; $i++){

    echo "Send Message".$ex->publish("Test Message , key_".$i,$k_route)."\n";
}
$conn->disconnect();

